<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.5"/>
<title>GameEngine: C:/Users/Axel/Desktop/informatica/Projects/Workspace C++/Game Engine/src/CoreSystems/Gameloop.cpp Source File</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<script type="text/javascript">
  $(document).ready(initResizable);
  $(window).load(resizeHeight);
</script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/search.js"></script>
<script type="text/javascript">
  $(document).ready(function() { searchBox.OnSelectItem(0); });
</script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td style="padding-left: 0.5em;">
   <div id="projectname">GameEngine
   </div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.5 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search",false,'Search');
</script>
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Main&#160;Page</span></a></li>
      <li><a href="namespaces.html"><span>Namespaces</span></a></li>
      <li><a href="annotated.html"><span>Classes</span></a></li>
      <li class="current"><a href="files.html"><span>Files</span></a></li>
      <li>
        <div id="MSearchBox" class="MSearchBoxInactive">
        <span class="left">
          <img id="MSearchSelect" src="search/mag_sel.png"
               onmouseover="return searchBox.OnSearchSelectShow()"
               onmouseout="return searchBox.OnSearchSelectHide()"
               alt=""/>
          <input type="text" id="MSearchField" value="Search" accesskey="S"
               onfocus="searchBox.OnSearchFieldFocus(true)" 
               onblur="searchBox.OnSearchFieldFocus(false)" 
               onkeyup="searchBox.OnSearchFieldChange(event)"/>
          </span><span class="right">
            <a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a>
          </span>
        </div>
      </li>
    </ul>
  </div>
  <div id="navrow2" class="tabs2">
    <ul class="tablist">
      <li><a href="files.html"><span>File&#160;List</span></a></li>
      <li><a href="globals.html"><span>File&#160;Members</span></a></li>
    </ul>
  </div>
</div><!-- top -->
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
      <div id="nav-sync" class="sync"></div>
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
$(document).ready(function(){initNavTree('_gameloop_8cpp_source.html','');});
</script>
<div id="doc-content">
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
<a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(0)"><span class="SelectionMark">&#160;</span>All</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(1)"><span class="SelectionMark">&#160;</span>Classes</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(2)"><span class="SelectionMark">&#160;</span>Namespaces</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(3)"><span class="SelectionMark">&#160;</span>Files</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(4)"><span class="SelectionMark">&#160;</span>Functions</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(5)"><span class="SelectionMark">&#160;</span>Variables</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(6)"><span class="SelectionMark">&#160;</span>Friends</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(7)"><span class="SelectionMark">&#160;</span>Macros</a></div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div class="header">
  <div class="headertitle">
<div class="title">Gameloop.cpp</div>  </div>
</div><!--header-->
<div class="contents">
<a href="_gameloop_8cpp.html">Go to the documentation of this file.</a><div class="fragment"><div class="line"><a name="l00001"></a><span class="lineno">    1</span>&#160;<span class="comment">/*</span></div>
<div class="line"><a name="l00002"></a><span class="lineno">    2</span>&#160;<span class="comment"> * Gameloop.cpp</span></div>
<div class="line"><a name="l00003"></a><span class="lineno">    3</span>&#160;<span class="comment"> *</span></div>
<div class="line"><a name="l00004"></a><span class="lineno">    4</span>&#160;<span class="comment"> *  Created on: 2-dec.-2013</span></div>
<div class="line"><a name="l00005"></a><span class="lineno">    5</span>&#160;<span class="comment"> *      Author: Axel</span></div>
<div class="line"><a name="l00006"></a><span class="lineno">    6</span>&#160;<span class="comment"> */</span></div>
<div class="line"><a name="l00007"></a><span class="lineno">    7</span>&#160;</div>
<div class="line"><a name="l00008"></a><span class="lineno">    8</span>&#160;<span class="preprocessor">#include &lt;<a class="code" href="_gameloop_8h.html">Gameloop.h</a>&gt;</span></div>
<div class="line"><a name="l00009"></a><span class="lineno">    9</span>&#160;</div>
<div class="line"><a name="l00010"></a><span class="lineno">   10</span>&#160;<span class="preprocessor">#include &lt;<a class="code" href="_string_8h.html">string.h</a>&gt;</span></div>
<div class="line"><a name="l00011"></a><span class="lineno">   11</span>&#160;<span class="preprocessor">#include &lt;iostream&gt;</span></div>
<div class="line"><a name="l00012"></a><span class="lineno">   12</span>&#160;<span class="preprocessor">#include &lt;GL/glew.h&gt;</span></div>
<div class="line"><a name="l00013"></a><span class="lineno">   13</span>&#160;<span class="preprocessor">#include &lt;glfw3.h&gt;</span></div>
<div class="line"><a name="l00014"></a><span class="lineno">   14</span>&#160;<span class="preprocessor">#include &lt;ctime&gt;</span></div>
<div class="line"><a name="l00015"></a><span class="lineno">   15</span>&#160;</div>
<div class="line"><a name="l00016"></a><span class="lineno">   16</span>&#160;<span class="comment">//set the total fps and time</span></div>
<div class="line"><a name="l00017"></a><span class="lineno">   17</span>&#160;<span class="keyword">const</span> <span class="keywordtype">double</span> <a class="code" href="class_gameloop.html#ae2dd6353df16267b2e9cbc845118721e">Gameloop::FPS</a> = 60;</div>
<div class="line"><a name="l00018"></a><span class="lineno">   18</span>&#160;<span class="keywordtype">int</span> <a class="code" href="class_gameloop.html#ae4cbe1048a5e5f398271d0d998b45028">Gameloop::timer</a> = 0;</div>
<div class="line"><a name="l00019"></a><span class="lineno">   19</span>&#160;</div>
<div class="line"><a name="l00020"></a><span class="lineno"><a class="line" href="class_gameloop.html#a18f9a1686565e206b40718ed787aeb97">   20</a></span>&#160;<a class="code" href="class_gameloop.html#a18f9a1686565e206b40718ed787aeb97">Gameloop::Gameloop</a>() {</div>
<div class="line"><a name="l00021"></a><span class="lineno">   21</span>&#160;    <span class="comment">//make the gameloop able to run</span></div>
<div class="line"><a name="l00022"></a><span class="lineno">   22</span>&#160;    <a class="code" href="class_gameloop.html#a9415733a7e81365c8b5b8ee5b1519ffb">running</a>=<span class="keyword">true</span>;</div>
<div class="line"><a name="l00023"></a><span class="lineno">   23</span>&#160;    <a class="code" href="class_gameloop.html#a301c183e1c307488fd2da2b0a19f7199">lastFrame</a> = 0;</div>
<div class="line"><a name="l00024"></a><span class="lineno">   24</span>&#160;    <span class="comment">//initiate the state manager</span></div>
<div class="line"><a name="l00025"></a><span class="lineno">   25</span>&#160;    <a class="code" href="class_gameloop.html#a2a19e25d1250c978750fadfe74cfde57">manager</a> = <span class="keyword">new</span> <a class="code" href="class_state_manager.html">StateManager</a>();</div>
<div class="line"><a name="l00026"></a><span class="lineno">   26</span>&#160;    <span class="comment">//initiate the game window</span></div>
<div class="line"><a name="l00027"></a><span class="lineno">   27</span>&#160;    <a class="code" href="class_gameloop.html#abf8e7512d69339437c10cfb24be80de2">window</a> = <span class="keyword">new</span> <a class="code" href="class_window.html">Window</a>(800, 600, <a class="code" href="_linked_list_8h.html#a070d2ce7b6bb7e5c05602aa8c308d0c4">NULL</a>);</div>
<div class="line"><a name="l00028"></a><span class="lineno">   28</span>&#160;    <span class="comment">//initialise the current state</span></div>
<div class="line"><a name="l00029"></a><span class="lineno">   29</span>&#160;    <a class="code" href="class_gameloop.html#af40baffa9da33a7f8d4e480244d74e74">currentState</a> = <a class="code" href="class_gameloop.html#a2a19e25d1250c978750fadfe74cfde57">manager</a>-&gt;<a class="code" href="class_state_manager.html#ae7672f878bc520a29723feac8dc19131">initialiseState</a>();</div>
<div class="line"><a name="l00030"></a><span class="lineno">   30</span>&#160;}</div>
<div class="line"><a name="l00031"></a><span class="lineno">   31</span>&#160;</div>
<div class="line"><a name="l00032"></a><span class="lineno">   32</span>&#160;<span class="comment">//delete the gathered recourses</span></div>
<div class="line"><a name="l00033"></a><span class="lineno"><a class="line" href="class_gameloop.html#ac0aff9533f00b23557a7d7b348b95007">   33</a></span>&#160;<a class="code" href="class_gameloop.html#ac0aff9533f00b23557a7d7b348b95007">Gameloop::~Gameloop</a>() {</div>
<div class="line"><a name="l00034"></a><span class="lineno">   34</span>&#160;    <span class="comment">//delete manager and window</span></div>
<div class="line"><a name="l00035"></a><span class="lineno">   35</span>&#160;    <span class="keyword">delete</span> <a class="code" href="class_gameloop.html#a2a19e25d1250c978750fadfe74cfde57">manager</a>;</div>
<div class="line"><a name="l00036"></a><span class="lineno">   36</span>&#160;    <span class="keyword">delete</span> <a class="code" href="class_gameloop.html#abf8e7512d69339437c10cfb24be80de2">window</a>;</div>
<div class="line"><a name="l00037"></a><span class="lineno">   37</span>&#160;}</div>
<div class="line"><a name="l00038"></a><span class="lineno">   38</span>&#160;</div>
<div class="line"><a name="l00039"></a><span class="lineno">   39</span>&#160;<span class="comment">//the core game loop</span></div>
<div class="line"><a name="l00040"></a><span class="lineno"><a class="line" href="class_gameloop.html#aaf57f38f17343877c7b4bd6a75ef3a9f">   40</a></span>&#160;<span class="keywordtype">void</span> <a class="code" href="class_gameloop.html#aaf57f38f17343877c7b4bd6a75ef3a9f">Gameloop::gameLoop</a>() {</div>
<div class="line"><a name="l00041"></a><span class="lineno">   41</span>&#160;    <span class="comment">//time in ms, when last updated</span></div>
<div class="line"><a name="l00042"></a><span class="lineno">   42</span>&#160;    <span class="keywordtype">double</span> lastUpdateTime = <a class="code" href="class_gameloop.html#a0004bb5d123525c760e16535c424d50b">getTime</a>();</div>
<div class="line"><a name="l00043"></a><span class="lineno">   43</span>&#160;    <span class="comment">//average time in ms per frame</span></div>
<div class="line"><a name="l00044"></a><span class="lineno">   44</span>&#160;    <span class="keyword">const</span> <span class="keywordtype">double</span> TIME = 1000 / <a class="code" href="class_gameloop.html#ae2dd6353df16267b2e9cbc845118721e">FPS</a>;</div>
<div class="line"><a name="l00045"></a><span class="lineno">   45</span>&#160;    <span class="comment">//maximum number of updates per frame</span></div>
<div class="line"><a name="l00046"></a><span class="lineno">   46</span>&#160;    <span class="keyword">const</span> <span class="keywordtype">int</span> MAXSKIP = 1;</div>
<div class="line"><a name="l00047"></a><span class="lineno">   47</span>&#160;    <span class="comment">//counts the number of updates</span></div>
<div class="line"><a name="l00048"></a><span class="lineno">   48</span>&#160;    <span class="keywordtype">int</span> loops=0;</div>
<div class="line"><a name="l00049"></a><span class="lineno">   49</span>&#160;    <span class="comment">//counter for the actual frames and updates</span></div>
<div class="line"><a name="l00050"></a><span class="lineno">   50</span>&#160;    <span class="keywordtype">int</span> countFrames=0;</div>
<div class="line"><a name="l00051"></a><span class="lineno">   51</span>&#160;    <span class="keywordtype">int</span> renders=0;</div>
<div class="line"><a name="l00052"></a><span class="lineno">   52</span>&#160;    <span class="keywordtype">int</span> lastSecondTime = (int) (lastUpdateTime / 1000);</div>
<div class="line"><a name="l00053"></a><span class="lineno">   53</span>&#160;</div>
<div class="line"><a name="l00054"></a><span class="lineno">   54</span>&#160;    <span class="keywordflow">while</span> (<a class="code" href="class_gameloop.html#a9415733a7e81365c8b5b8ee5b1519ffb">running</a> &amp;&amp; !<a class="code" href="class_gameloop.html#abf8e7512d69339437c10cfb24be80de2">window</a>-&gt;<a class="code" href="class_window.html#a8bcacaa3d5668366e879d6c68633ac40">closeWindow</a>()) {</div>
<div class="line"><a name="l00055"></a><span class="lineno">   55</span>&#160;</div>
<div class="line"><a name="l00056"></a><span class="lineno">   56</span>&#160;        <span class="comment">//Update the Game and Handling Input</span></div>
<div class="line"><a name="l00057"></a><span class="lineno">   57</span>&#160;        loops=0;</div>
<div class="line"><a name="l00058"></a><span class="lineno">   58</span>&#160;        <span class="keywordflow">while</span> ((<a class="code" href="class_gameloop.html#a0004bb5d123525c760e16535c424d50b">getTime</a>()&gt;lastUpdateTime) &amp;&amp; (loops &lt; MAXSKIP)) {</div>
<div class="line"><a name="l00059"></a><span class="lineno">   59</span>&#160;            <span class="comment">//update and handle input</span></div>
<div class="line"><a name="l00060"></a><span class="lineno">   60</span>&#160;            <a class="code" href="class_gameloop.html#a363757057c85482cecc4f72da4084dba">update</a>();</div>
<div class="line"><a name="l00061"></a><span class="lineno">   61</span>&#160;            <a class="code" href="class_gameloop.html#a1fc46b06b36562f628e0d8f051c8b596">handleInput</a>();</div>
<div class="line"><a name="l00062"></a><span class="lineno">   62</span>&#160;</div>
<div class="line"><a name="l00063"></a><span class="lineno">   63</span>&#160;            <span class="comment">//increase the updateTime</span></div>
<div class="line"><a name="l00064"></a><span class="lineno">   64</span>&#160;            lastUpdateTime += TIME;</div>
<div class="line"><a name="l00065"></a><span class="lineno">   65</span>&#160;            loops++;</div>
<div class="line"><a name="l00066"></a><span class="lineno">   66</span>&#160;            <a class="code" href="class_gameloop.html#ae4cbe1048a5e5f398271d0d998b45028">timer</a>++;</div>
<div class="line"><a name="l00067"></a><span class="lineno">   67</span>&#160;</div>
<div class="line"><a name="l00068"></a><span class="lineno">   68</span>&#160;            countFrames++;</div>
<div class="line"><a name="l00069"></a><span class="lineno">   69</span>&#160;        }</div>
<div class="line"><a name="l00070"></a><span class="lineno">   70</span>&#160;</div>
<div class="line"><a name="l00071"></a><span class="lineno">   71</span>&#160;        <span class="comment">// Render the game</span></div>
<div class="line"><a name="l00072"></a><span class="lineno">   72</span>&#160;        <span class="comment">//calculate an interpolation to aid the rendering</span></div>
<div class="line"><a name="l00073"></a><span class="lineno">   73</span>&#160;        <span class="keywordtype">float</span> interpolation = float(<a class="code" href="class_gameloop.html#a0004bb5d123525c760e16535c424d50b">getTime</a>() + TIME - lastUpdateTime)/ float( TIME);</div>
<div class="line"><a name="l00074"></a><span class="lineno">   74</span>&#160;        <a class="code" href="class_gameloop.html#a6f65b70ec85e73fb4467e7eb34bc4849">render</a>(interpolation);</div>
<div class="line"><a name="l00075"></a><span class="lineno">   75</span>&#160;        renders++;</div>
<div class="line"><a name="l00076"></a><span class="lineno">   76</span>&#160;</div>
<div class="line"><a name="l00077"></a><span class="lineno">   77</span>&#160;        <span class="comment">//calculate the current second</span></div>
<div class="line"><a name="l00078"></a><span class="lineno">   78</span>&#160;        <span class="comment">//print out the frames and updates</span></div>
<div class="line"><a name="l00079"></a><span class="lineno">   79</span>&#160;        <span class="keywordtype">int</span> thisSecond = (int) (lastUpdateTime / 1000);</div>
<div class="line"><a name="l00080"></a><span class="lineno">   80</span>&#160;        <span class="keywordflow">if</span> (thisSecond &gt; lastSecondTime){</div>
<div class="line"><a name="l00081"></a><span class="lineno">   81</span>&#160;            std::cout &lt;&lt; <span class="stringliteral">&quot;NEW SECOND &quot;</span> &lt;&lt; thisSecond &lt;&lt; <span class="stringliteral">&quot; &quot;</span> &lt;&lt; countFrames  &lt;&lt; <span class="stringliteral">&quot; Renders: &quot;</span> &lt;&lt; renders &lt;&lt; std::endl;</div>
<div class="line"><a name="l00082"></a><span class="lineno">   82</span>&#160;            countFrames=0;</div>
<div class="line"><a name="l00083"></a><span class="lineno">   83</span>&#160;            renders=0;</div>
<div class="line"><a name="l00084"></a><span class="lineno">   84</span>&#160;            lastSecondTime = thisSecond;</div>
<div class="line"><a name="l00085"></a><span class="lineno">   85</span>&#160;        }</div>
<div class="line"><a name="l00086"></a><span class="lineno">   86</span>&#160;    }</div>
<div class="line"><a name="l00087"></a><span class="lineno">   87</span>&#160;}</div>
<div class="line"><a name="l00088"></a><span class="lineno">   88</span>&#160;</div>
<div class="line"><a name="l00089"></a><span class="lineno">   89</span>&#160;</div>
<div class="line"><a name="l00090"></a><span class="lineno">   90</span>&#160;<span class="comment">//Will return time in milliseconds</span></div>
<div class="line"><a name="l00091"></a><span class="lineno"><a class="line" href="class_gameloop.html#a0004bb5d123525c760e16535c424d50b">   91</a></span>&#160;<span class="keywordtype">long</span> <a class="code" href="class_gameloop.html#a0004bb5d123525c760e16535c424d50b">Gameloop::getTime</a>(){</div>
<div class="line"><a name="l00092"></a><span class="lineno">   92</span>&#160;    <span class="keywordflow">return</span> clock();</div>
<div class="line"><a name="l00093"></a><span class="lineno">   93</span>&#160;}</div>
<div class="line"><a name="l00094"></a><span class="lineno">   94</span>&#160;</div>
<div class="line"><a name="l00095"></a><span class="lineno">   95</span>&#160;</div>
<div class="line"><a name="l00096"></a><span class="lineno">   96</span>&#160;<span class="comment">//stop the game loop</span></div>
<div class="line"><a name="l00097"></a><span class="lineno"><a class="line" href="class_gameloop.html#a91d555830ff70f604077ec1600bf9a90">   97</a></span>&#160;<span class="keywordtype">void</span> <a class="code" href="class_gameloop.html#a91d555830ff70f604077ec1600bf9a90">Gameloop::stopLoop</a>(){</div>
<div class="line"><a name="l00098"></a><span class="lineno">   98</span>&#160;    <a class="code" href="class_gameloop.html#a9415733a7e81365c8b5b8ee5b1519ffb">running</a>=<span class="keyword">false</span>;</div>
<div class="line"><a name="l00099"></a><span class="lineno">   99</span>&#160;}</div>
<div class="line"><a name="l00100"></a><span class="lineno">  100</span>&#160;</div>
<div class="line"><a name="l00101"></a><span class="lineno">  101</span>&#160;<span class="comment">//rendering the screen</span></div>
<div class="line"><a name="l00102"></a><span class="lineno"><a class="line" href="class_gameloop.html#a6f65b70ec85e73fb4467e7eb34bc4849">  102</a></span>&#160;<span class="keywordtype">void</span> <a class="code" href="class_gameloop.html#a6f65b70ec85e73fb4467e7eb34bc4849">Gameloop::render</a>(<span class="keywordtype">float</span> interpolation){</div>
<div class="line"><a name="l00103"></a><span class="lineno">  103</span>&#160;    <span class="comment">//clears the screen to black</span></div>
<div class="line"><a name="l00104"></a><span class="lineno">  104</span>&#160;    glClearColor(0.0f, 0.0f, 0.0f, 0.0f);</div>
<div class="line"><a name="l00105"></a><span class="lineno">  105</span>&#160;    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);</div>
<div class="line"><a name="l00106"></a><span class="lineno">  106</span>&#160;</div>
<div class="line"><a name="l00107"></a><span class="lineno">  107</span>&#160;    <span class="comment">//do the rendering</span></div>
<div class="line"><a name="l00108"></a><span class="lineno">  108</span>&#160;    <a class="code" href="class_gameloop.html#af40baffa9da33a7f8d4e480244d74e74">currentState</a>-&gt;<a class="code" href="class_state_machine.html#a0fabb1a7bbbda3158636cec08623a66e">renderGame</a>(interpolation);</div>
<div class="line"><a name="l00109"></a><span class="lineno">  109</span>&#160;</div>
<div class="line"><a name="l00110"></a><span class="lineno">  110</span>&#160;    <span class="comment">//Swap front and back buffers</span></div>
<div class="line"><a name="l00111"></a><span class="lineno">  111</span>&#160;    <a class="code" href="class_gameloop.html#abf8e7512d69339437c10cfb24be80de2">window</a>-&gt;<a class="code" href="class_window.html#a01fbb42b7e6ebe0f93ab3d2b26212253">swapBuffer</a>();</div>
<div class="line"><a name="l00112"></a><span class="lineno">  112</span>&#160;}</div>
<div class="line"><a name="l00113"></a><span class="lineno">  113</span>&#160;</div>
<div class="line"><a name="l00114"></a><span class="lineno">  114</span>&#160;<span class="comment">//update the game logic</span></div>
<div class="line"><a name="l00115"></a><span class="lineno"><a class="line" href="class_gameloop.html#a363757057c85482cecc4f72da4084dba">  115</a></span>&#160;<span class="keywordtype">void</span> <a class="code" href="class_gameloop.html#a363757057c85482cecc4f72da4084dba">Gameloop::update</a>(){</div>
<div class="line"><a name="l00116"></a><span class="lineno">  116</span>&#160;    <span class="comment">//update game positions</span></div>
<div class="line"><a name="l00117"></a><span class="lineno">  117</span>&#160;    <a class="code" href="class_gameloop.html#af40baffa9da33a7f8d4e480244d74e74">currentState</a>-&gt;<a class="code" href="class_state_machine.html#a6ed723b00e78eac46515b636c5a8481e">updateGame</a>(<a class="code" href="class_gameloop.html#ae4cbe1048a5e5f398271d0d998b45028">timer</a>);</div>
<div class="line"><a name="l00118"></a><span class="lineno">  118</span>&#160;    <span class="keywordflow">if</span> (<a class="code" href="class_gameloop.html#af40baffa9da33a7f8d4e480244d74e74">currentState</a>-&gt;<a class="code" href="class_state_machine.html#aab3dd552f209ece70f8913a5fd4449db">stateChanger</a>()!=0){</div>
<div class="line"><a name="l00119"></a><span class="lineno">  119</span>&#160;        <span class="comment">//change the state</span></div>
<div class="line"><a name="l00120"></a><span class="lineno">  120</span>&#160;        <a class="code" href="class_gameloop.html#a7c190e11c2ed38b078519efe7e4d06d2">changeState</a>(<a class="code" href="class_gameloop.html#a2a19e25d1250c978750fadfe74cfde57">manager</a>-&gt;<a class="code" href="class_state_manager.html#ada4df5f0156c3f811fc2fb4fb4991d8f">callStates</a>(<a class="code" href="class_gameloop.html#af40baffa9da33a7f8d4e480244d74e74">currentState</a>-&gt;<a class="code" href="class_state_machine.html#aab3dd552f209ece70f8913a5fd4449db">stateChanger</a>(), <a class="code" href="class_gameloop.html#af40baffa9da33a7f8d4e480244d74e74">currentState</a>-&gt;<a class="code" href="class_state_machine.html#a39949e8a92cdca4854ac5394d6e0ba42">getKeyCode</a>(), <a class="code" href="class_gameloop.html#af40baffa9da33a7f8d4e480244d74e74">currentState</a>));</div>
<div class="line"><a name="l00121"></a><span class="lineno">  121</span>&#160;    }</div>
<div class="line"><a name="l00122"></a><span class="lineno">  122</span>&#160;}</div>
<div class="line"><a name="l00123"></a><span class="lineno">  123</span>&#160;</div>
<div class="line"><a name="l00124"></a><span class="lineno">  124</span>&#160;<span class="comment">// Poll for and process events</span></div>
<div class="line"><a name="l00125"></a><span class="lineno"><a class="line" href="class_gameloop.html#a1fc46b06b36562f628e0d8f051c8b596">  125</a></span>&#160;<span class="keywordtype">void</span> <a class="code" href="class_gameloop.html#a1fc46b06b36562f628e0d8f051c8b596">Gameloop::handleInput</a>(){</div>
<div class="line"><a name="l00126"></a><span class="lineno">  126</span>&#160;    <span class="comment">//let the window collect input</span></div>
<div class="line"><a name="l00127"></a><span class="lineno">  127</span>&#160;    <a class="code" href="class_gameloop.html#abf8e7512d69339437c10cfb24be80de2">window</a>-&gt;<a class="code" href="class_window.html#a2110b0bed3ca157e2e46d9ff5a857a14">handleInput</a>();</div>
<div class="line"><a name="l00128"></a><span class="lineno">  128</span>&#160;    <span class="comment">//forward the input</span></div>
<div class="line"><a name="l00129"></a><span class="lineno">  129</span>&#160;    <a class="code" href="class_gameloop.html#af40baffa9da33a7f8d4e480244d74e74">currentState</a>-&gt;<a class="code" href="class_state_machine.html#a2f89dc242f85ca11d6eb400ffa6499bf">handleInput</a>(<a class="code" href="class_gameloop.html#abf8e7512d69339437c10cfb24be80de2">window</a>-&gt;<a class="code" href="class_window.html#a0a091d94124d3d94a2ce6fc30d9883a8">getWindow</a>());</div>
<div class="line"><a name="l00130"></a><span class="lineno">  130</span>&#160;}</div>
<div class="line"><a name="l00131"></a><span class="lineno">  131</span>&#160;</div>
<div class="line"><a name="l00132"></a><span class="lineno">  132</span>&#160;<span class="comment">//change the state</span></div>
<div class="line"><a name="l00133"></a><span class="lineno"><a class="line" href="class_gameloop.html#a7c190e11c2ed38b078519efe7e4d06d2">  133</a></span>&#160;<span class="keywordtype">void</span> <a class="code" href="class_gameloop.html#a7c190e11c2ed38b078519efe7e4d06d2">Gameloop::changeState</a>(<a class="code" href="class_state_machine.html">StateMachine</a>* level){</div>
<div class="line"><a name="l00134"></a><span class="lineno">  134</span>&#160;    <a class="code" href="class_gameloop.html#af40baffa9da33a7f8d4e480244d74e74">currentState</a> = level;</div>
<div class="line"><a name="l00135"></a><span class="lineno">  135</span>&#160;}</div>
<div class="line"><a name="l00136"></a><span class="lineno">  136</span>&#160;</div>
<div class="ttc" id="class_state_machine_html"><div class="ttname"><a href="class_state_machine.html">StateMachine</a></div><div class="ttdef"><b>Definition:</b> <a href="_state_machine_8h_source.html#l00014">StateMachine.h:14</a></div></div>
<div class="ttc" id="class_gameloop_html_ae4cbe1048a5e5f398271d0d998b45028"><div class="ttname"><a href="class_gameloop.html#ae4cbe1048a5e5f398271d0d998b45028">Gameloop::timer</a></div><div class="ttdeci">static int timer</div><div class="ttdef"><b>Definition:</b> <a href="_gameloop_8h_source.html#l00042">Gameloop.h:42</a></div></div>
<div class="ttc" id="class_window_html"><div class="ttname"><a href="class_window.html">Window</a></div><div class="ttdef"><b>Definition:</b> <a href="_window_8h_source.html#l00011">Window.h:11</a></div></div>
<div class="ttc" id="class_gameloop_html_a7c190e11c2ed38b078519efe7e4d06d2"><div class="ttname"><a href="class_gameloop.html#a7c190e11c2ed38b078519efe7e4d06d2">Gameloop::changeState</a></div><div class="ttdeci">void changeState(StateMachine *level)</div><div class="ttdef"><b>Definition:</b> <a href="_gameloop_8cpp_source.html#l00133">Gameloop.cpp:133</a></div></div>
<div class="ttc" id="class_gameloop_html_a2a19e25d1250c978750fadfe74cfde57"><div class="ttname"><a href="class_gameloop.html#a2a19e25d1250c978750fadfe74cfde57">Gameloop::manager</a></div><div class="ttdeci">StateManager * manager</div><div class="ttdef"><b>Definition:</b> <a href="_gameloop_8h_source.html#l00046">Gameloop.h:46</a></div></div>
<div class="ttc" id="_gameloop_8h_html"><div class="ttname"><a href="_gameloop_8h.html">Gameloop.h</a></div></div>
<div class="ttc" id="_linked_list_8h_html_a070d2ce7b6bb7e5c05602aa8c308d0c4"><div class="ttname"><a href="_linked_list_8h.html#a070d2ce7b6bb7e5c05602aa8c308d0c4">NULL</a></div><div class="ttdeci">#define NULL</div><div class="ttdef"><b>Definition:</b> <a href="_linked_list_8h_source.html#l00012">LinkedList.h:12</a></div></div>
<div class="ttc" id="class_gameloop_html_a91d555830ff70f604077ec1600bf9a90"><div class="ttname"><a href="class_gameloop.html#a91d555830ff70f604077ec1600bf9a90">Gameloop::stopLoop</a></div><div class="ttdeci">void stopLoop()</div><div class="ttdef"><b>Definition:</b> <a href="_gameloop_8cpp_source.html#l00097">Gameloop.cpp:97</a></div></div>
<div class="ttc" id="class_gameloop_html_af40baffa9da33a7f8d4e480244d74e74"><div class="ttname"><a href="class_gameloop.html#af40baffa9da33a7f8d4e480244d74e74">Gameloop::currentState</a></div><div class="ttdeci">StateMachine * currentState</div><div class="ttdef"><b>Definition:</b> <a href="_gameloop_8h_source.html#l00045">Gameloop.h:45</a></div></div>
<div class="ttc" id="class_state_manager_html"><div class="ttname"><a href="class_state_manager.html">StateManager</a></div><div class="ttdef"><b>Definition:</b> <a href="_state_manager_8h_source.html#l00015">StateManager.h:15</a></div></div>
<div class="ttc" id="class_state_machine_html_a2f89dc242f85ca11d6eb400ffa6499bf"><div class="ttname"><a href="class_state_machine.html#a2f89dc242f85ca11d6eb400ffa6499bf">StateMachine::handleInput</a></div><div class="ttdeci">virtual void handleInput(GLFWwindow *window)=0</div></div>
<div class="ttc" id="class_gameloop_html_aaf57f38f17343877c7b4bd6a75ef3a9f"><div class="ttname"><a href="class_gameloop.html#aaf57f38f17343877c7b4bd6a75ef3a9f">Gameloop::gameLoop</a></div><div class="ttdeci">void gameLoop()</div><div class="ttdef"><b>Definition:</b> <a href="_gameloop_8cpp_source.html#l00040">Gameloop.cpp:40</a></div></div>
<div class="ttc" id="class_state_manager_html_ae7672f878bc520a29723feac8dc19131"><div class="ttname"><a href="class_state_manager.html#ae7672f878bc520a29723feac8dc19131">StateManager::initialiseState</a></div><div class="ttdeci">StateMachine * initialiseState()</div><div class="ttdef"><b>Definition:</b> <a href="_state_manager_8cpp_source.html#l00022">StateManager.cpp:22</a></div></div>
<div class="ttc" id="class_gameloop_html_a18f9a1686565e206b40718ed787aeb97"><div class="ttname"><a href="class_gameloop.html#a18f9a1686565e206b40718ed787aeb97">Gameloop::Gameloop</a></div><div class="ttdeci">Gameloop()</div><div class="ttdef"><b>Definition:</b> <a href="_gameloop_8cpp_source.html#l00020">Gameloop.cpp:20</a></div></div>
<div class="ttc" id="class_gameloop_html_ae2dd6353df16267b2e9cbc845118721e"><div class="ttname"><a href="class_gameloop.html#ae2dd6353df16267b2e9cbc845118721e">Gameloop::FPS</a></div><div class="ttdeci">static const double FPS</div><div class="ttdef"><b>Definition:</b> <a href="_gameloop_8h_source.html#l00041">Gameloop.h:41</a></div></div>
<div class="ttc" id="class_gameloop_html_ac0aff9533f00b23557a7d7b348b95007"><div class="ttname"><a href="class_gameloop.html#ac0aff9533f00b23557a7d7b348b95007">Gameloop::~Gameloop</a></div><div class="ttdeci">virtual ~Gameloop()</div><div class="ttdef"><b>Definition:</b> <a href="_gameloop_8cpp_source.html#l00033">Gameloop.cpp:33</a></div></div>
<div class="ttc" id="class_gameloop_html_a0004bb5d123525c760e16535c424d50b"><div class="ttname"><a href="class_gameloop.html#a0004bb5d123525c760e16535c424d50b">Gameloop::getTime</a></div><div class="ttdeci">long getTime()</div><div class="ttdef"><b>Definition:</b> <a href="_gameloop_8cpp_source.html#l00091">Gameloop.cpp:91</a></div></div>
<div class="ttc" id="class_gameloop_html_a301c183e1c307488fd2da2b0a19f7199"><div class="ttname"><a href="class_gameloop.html#a301c183e1c307488fd2da2b0a19f7199">Gameloop::lastFrame</a></div><div class="ttdeci">long lastFrame</div><div class="ttdef"><b>Definition:</b> <a href="_gameloop_8h_source.html#l00037">Gameloop.h:37</a></div></div>
<div class="ttc" id="class_gameloop_html_abf8e7512d69339437c10cfb24be80de2"><div class="ttname"><a href="class_gameloop.html#abf8e7512d69339437c10cfb24be80de2">Gameloop::window</a></div><div class="ttdeci">Window * window</div><div class="ttdef"><b>Definition:</b> <a href="_gameloop_8h_source.html#l00034">Gameloop.h:34</a></div></div>
<div class="ttc" id="class_gameloop_html_a6f65b70ec85e73fb4467e7eb34bc4849"><div class="ttname"><a href="class_gameloop.html#a6f65b70ec85e73fb4467e7eb34bc4849">Gameloop::render</a></div><div class="ttdeci">void render(float interpolation)</div><div class="ttdef"><b>Definition:</b> <a href="_gameloop_8cpp_source.html#l00102">Gameloop.cpp:102</a></div></div>
<div class="ttc" id="class_window_html_a01fbb42b7e6ebe0f93ab3d2b26212253"><div class="ttname"><a href="class_window.html#a01fbb42b7e6ebe0f93ab3d2b26212253">Window::swapBuffer</a></div><div class="ttdeci">void swapBuffer()</div><div class="ttdef"><b>Definition:</b> <a href="_window_8cpp_source.html#l00035">Window.cpp:35</a></div></div>
<div class="ttc" id="class_gameloop_html_a363757057c85482cecc4f72da4084dba"><div class="ttname"><a href="class_gameloop.html#a363757057c85482cecc4f72da4084dba">Gameloop::update</a></div><div class="ttdeci">void update()</div><div class="ttdef"><b>Definition:</b> <a href="_gameloop_8cpp_source.html#l00115">Gameloop.cpp:115</a></div></div>
<div class="ttc" id="class_gameloop_html_a9415733a7e81365c8b5b8ee5b1519ffb"><div class="ttname"><a href="class_gameloop.html#a9415733a7e81365c8b5b8ee5b1519ffb">Gameloop::running</a></div><div class="ttdeci">bool running</div><div class="ttdef"><b>Definition:</b> <a href="_gameloop_8h_source.html#l00038">Gameloop.h:38</a></div></div>
<div class="ttc" id="class_state_machine_html_a6ed723b00e78eac46515b636c5a8481e"><div class="ttname"><a href="class_state_machine.html#a6ed723b00e78eac46515b636c5a8481e">StateMachine::updateGame</a></div><div class="ttdeci">virtual void updateGame(int timer)=0</div></div>
<div class="ttc" id="class_state_machine_html_aab3dd552f209ece70f8913a5fd4449db"><div class="ttname"><a href="class_state_machine.html#aab3dd552f209ece70f8913a5fd4449db">StateMachine::stateChanger</a></div><div class="ttdeci">virtual long stateChanger()=0</div></div>
<div class="ttc" id="class_state_machine_html_a39949e8a92cdca4854ac5394d6e0ba42"><div class="ttname"><a href="class_state_machine.html#a39949e8a92cdca4854ac5394d6e0ba42">StateMachine::getKeyCode</a></div><div class="ttdeci">virtual long getKeyCode()=0</div></div>
<div class="ttc" id="class_window_html_a2110b0bed3ca157e2e46d9ff5a857a14"><div class="ttname"><a href="class_window.html#a2110b0bed3ca157e2e46d9ff5a857a14">Window::handleInput</a></div><div class="ttdeci">void handleInput()</div><div class="ttdef"><b>Definition:</b> <a href="_window_8cpp_source.html#l00040">Window.cpp:40</a></div></div>
<div class="ttc" id="_string_8h_html"><div class="ttname"><a href="_string_8h.html">String.h</a></div></div>
<div class="ttc" id="class_state_manager_html_ada4df5f0156c3f811fc2fb4fb4991d8f"><div class="ttname"><a href="class_state_manager.html#ada4df5f0156c3f811fc2fb4fb4991d8f">StateManager::callStates</a></div><div class="ttdeci">StateMachine * callStates(long code, long oldcode, StateMachine *oldmachine)</div><div class="ttdef"><b>Definition:</b> <a href="_state_manager_8cpp_source.html#l00035">StateManager.cpp:35</a></div></div>
<div class="ttc" id="class_window_html_a0a091d94124d3d94a2ce6fc30d9883a8"><div class="ttname"><a href="class_window.html#a0a091d94124d3d94a2ce6fc30d9883a8">Window::getWindow</a></div><div class="ttdeci">GLFWwindow * getWindow()</div><div class="ttdef"><b>Definition:</b> <a href="_window_8cpp_source.html#l00045">Window.cpp:45</a></div></div>
<div class="ttc" id="class_state_machine_html_a0fabb1a7bbbda3158636cec08623a66e"><div class="ttname"><a href="class_state_machine.html#a0fabb1a7bbbda3158636cec08623a66e">StateMachine::renderGame</a></div><div class="ttdeci">virtual void renderGame(float interpolation)=0</div></div>
<div class="ttc" id="class_window_html_a8bcacaa3d5668366e879d6c68633ac40"><div class="ttname"><a href="class_window.html#a8bcacaa3d5668366e879d6c68633ac40">Window::closeWindow</a></div><div class="ttdeci">bool closeWindow()</div><div class="ttdef"><b>Definition:</b> <a href="_window_8cpp_source.html#l00030">Window.cpp:30</a></div></div>
<div class="ttc" id="class_gameloop_html_a1fc46b06b36562f628e0d8f051c8b596"><div class="ttname"><a href="class_gameloop.html#a1fc46b06b36562f628e0d8f051c8b596">Gameloop::handleInput</a></div><div class="ttdeci">void handleInput()</div><div class="ttdef"><b>Definition:</b> <a href="_gameloop_8cpp_source.html#l00125">Gameloop.cpp:125</a></div></div>
</div><!-- fragment --></div><!-- contents -->
</div><!-- doc-content -->
<!-- start footer part -->
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
  <ul>
    <li class="navelem"><a class="el" href="dir_68267d1309a1af8e8297ef4c3efbcdba.html">src</a></li><li class="navelem"><a class="el" href="dir_019651478e64fa8531e8b52ba72014e7.html">CoreSystems</a></li><li class="navelem"><a class="el" href="_gameloop_8cpp.html">Gameloop.cpp</a></li>
    <li class="footer">Generated on Fri Dec 13 2013 19:38:39 for GameEngine by
    <a href="http://www.doxygen.org/index.html">
    <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.8.5 </li>
  </ul>
</div>
</body>
</html>
